/**
 * Copyright (c) 2007,中企动力华南研发中心<br>
 * All rights reserved.
 */
package com.ce.pms.charge.web;

import com.ce.pms.base.web.PmsBaseAction;
import com.ce.pms.charge.model.ParameterDefDomain;
import com.ce.pms.charge.service.IChargeItemService;
import com.ce.pms.charge.service.IParameterDefService;
import com.ce.pms.charge.vo.ParameterDefVO;
import com.sitechasia.webx.core.annotation.Read;
import com.sitechasia.webx.core.support.Page;

/**
 * 功能描述：参数预设<br>
 * @author 罗军林 创建日期：2008-8-6
 */
public class ParameterDefAction extends PmsBaseAction {
	IParameterDefService parameterDefService;
	IChargeItemService  chargeItemService;

	/**
	 * 功能描述:初始化主页面<br>
	 * <br>
	 * Create author:罗军林<br>
	 * Create on:2008-8-6<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public void initMain(){}

	public void initEdit(@Read(key = "keyword") Long parameterDefId){
		ParameterDefVO parameterDefVO=parameterDefService.findParameterDefByKeyword(parameterDefId);
		setAttribute("parameterDefVO", parameterDefVO);
	}

	public void edit(@Read ParameterDefVO parameterDefVO){
		parameterDefVO.setCreator(this.getUserId());
		parameterDefService.editParameterDef(parameterDefVO);
	}

	public void initSelectChargeItem(@Read(key="iframeName")String iframeName,
									@Read(key="code")String code){
		setAttribute("iframeName",iframeName);
		setAttribute("chargeItemList", chargeItemService.queryChargeItemListByName(code));
	}
	/**
	 * 功能描述:费用模块的参数预设列表<br>
	 * @param pageSize
	 * @param pageNo<br>
	 * Create author:罗军林<br>
	 * Create on:2008-8-6<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public void listAsCharge(@Read(key = "ec_crd",defaultValue="15") int pageSize,
					@Read(key = "ec_p",defaultValue="1")	int pageNo){
		ParameterDefVO condition=new ParameterDefVO();
		condition.setGkey(ParameterDefDomain.GKEY_CHARGE);
		Page page=parameterDefService.queryParameterDef(condition, pageNo, pageSize);

		setAttribute("totalRows", Integer.valueOf((int) page.getTotalCount()));
		setAttribute("parameterDeflist", page.getResult());
	}


	/**
	 * @return parameterDefServicegetParameterDefService
	 */
	public IParameterDefService getParameterDefService() {
		return parameterDefService;
	}

	/**
	 * @param parameterDefService the parameterDefService to set
	 */
	public void setParameterDefService(IParameterDefService parameterDefService) {
		this.parameterDefService = parameterDefService;
	}

	/**
	 * @param chargeItemService the chargeItemService to set
	 */
	public void setChargeItemService(IChargeItemService chargeItemService) {
		this.chargeItemService = chargeItemService;
	}

}
